home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util4 / 0utils.lha / 0Utils / ReadLn.data < prev    next >
Text File  |  1995-08-19  |  2KB  |  86 lines

  1.  
  2. #ifdef TPLTER
  3.  
  4. ReadLn = {
  5.  
  6.     SHORT = {{ Read Line[s] from a filehandle }};
  7.  
  8.     DESCRIPTION = {{
  9.     ReadLn reads linesfrom a filehandle previosly opened
  10.     with the 'Open' command. its purpose is to split the
  11.     contents of a certain file in order to be able to
  12.     handle it with different other commands, without a need
  13.     of using another scripting language (like e.g. ARexx).
  14.     ReadLn does no checks on the given filehandle, so
  15.     it should be used carefully.
  16.  
  17.      RESULT
  18.     the read lines
  19.     }};
  20.  
  21.     NOTES = {{
  22.     ! ReadLn is highly dangerous! Do not Use it, !
  23.     ! if U do not exactly know what U are doing! !
  24.     }};
  25.  
  26.  
  27.     EXAMPLES = {{
  28.     > set fh `Open Sys:S/Shell-startup`
  29.     > Readln $fh
  30.       alias xcopy "copy clone "
  31.     > Close $fh
  32.     > Unset fh
  33.     }};
  34.  
  35.     HISTORY = {{
  36.     21-02-95 b_noll created
  37.     21-02-95 b_noll added version/format-prefix/offset
  38.     20-03-95 b_noll added args diagnostics
  39.     20-03-95 b_noll ReadLn always skipped one line
  40.     19-08-95 b_noll created .data file
  41.     }};
  42.  
  43.  
  44.  
  45.     Template = "FILEHANDLE/N/A,LINES/N/K";
  46.     Arguments = {{
  47.     BPTR  *filehandle;
  48.     ULONG *lines;
  49.     }};
  50.  
  51.     version = "1.1";
  52.  
  53.     body = {{
  54.         if (argv->filehandle && *argv->filehandle) {
  55.         UBYTE buffer[MAXLINELEN];
  56.         ULONG lines = 1;
  57.  
  58.         /* MISSING: CHECKREGISTER(*argv->filehandle); */
  59.  
  60.         if (argv->lines) lines = *argv->lines;
  61.         retval = RETURN_OK;
  62.  
  63.         while ((retval == RETURN_OK) && lines && FGets(*argv->filehandle, buffer, MAXLINELEN)) {
  64.             -- lines;
  65.             if (PutStr(buffer)) {
  66.             retval = RETURN_ERROR;
  67.             //PrintFault(IoErr(), "Read");
  68.             } /* if */
  69.         } /* while */
  70.  
  71.         if (lines && !retval) {
  72.             //PrintFault(IoErr(), "Read");
  73.             retval = RETURN_WARN;
  74.         } /* if */
  75.         } else {
  76.         //PrintFault(ERROR_BAD_NUMBER, "Read");
  77.         SetIoErr(ERROR_BAD_NUMBER);
  78.         } /* if */
  79.  
  80.     }};
  81.  
  82. };
  83.  
  84. #endif
  85.  
  86.